import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SpuVo, SpuForm, SpuQuery } from '@/api/spu/spu/types';

/**
 * 查询商品信息列表
 * @param query
 * @returns {*}
 */

export const listSpu = (query?: SpuQuery): AxiosPromise<SpuVo[]> => {
  return request({
    url: '/lawyer/spu/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商品信息详细
 * @param spuId
 */
export const getSpu = (spuId: string | number): AxiosPromise<SpuVo> => {
  return request({
    url: '/lawyer/spu/' + spuId,
    method: 'get'
  });
};

/**
 * 新增商品信息
 * @param data
 */
export const addSpu = (data: SpuForm) => {
  return request({
    url: '/lawyer/spu/saveSpu',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品信息
 * @param data
 */
export const updateSpu = (data: SpuForm) => {
  return request({
    url: '/lawyer/spu/updateSpu',
    method: 'post',
    data: data
  });
};

/**
 * 删除商品信息
 * @param spuId
 */
export const delSpu = (spuId: string | number | Array<string | number>) => {
  return request({
    url: '/lawyer/spu/' + spuId,
    method: 'delete'
  });
};
